home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / ktextedit.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-05-22  |  4.9 KB  |  175 lines

  1. /* This file is part of the KDE libraries
  2.     Copyright (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
  3.  
  4.     This library is free software; you can redistribute it and/or
  5.     modify it under the terms of the GNU Library General Public
  6.     License as published by the Free Software Foundation; either
  7.     version 2 of the License, or (at your option) any later version.
  8.  
  9.     This library is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.     Library General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU Library General Public License
  15.     along with this library; see the file COPYING.LIB.  If not, write to
  16.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17.     Boston, MA 02110-1301, USA.
  18. */
  19.  
  20. #ifndef KTEXTEDIT_H
  21. #define KTEXTEDIT_H
  22.  
  23. #include <qtextedit.h>
  24.  
  25. #include <kdelibs_export.h>
  26.  
  27. class KSpell;
  28.  
  29. /**
  30.  * @short A KDE'ified QTextEdit
  31.  *
  32.  * This is just a little subclass of QTextEdit, implementing
  33.  * some standard KDE features, like Cursor auto-hiding, configurable
  34.  * wheelscrolling (fast-scroll or zoom) and deleting of entire
  35.  * words with Ctrl-Backspace or Ctrl-Delete.
  36.  *
  37.  * Basic rule: whenever you want to use QTextEdit, use KTextEdit!
  38.  *
  39.  * @see QTextEdit
  40.  * @author Carsten Pfeiffer <pfeiffer@kde.org>
  41.  * @since 3.1
  42.  */
  43. class KDEUI_EXPORT KTextEdit : public QTextEdit
  44. {
  45.     Q_OBJECT
  46.  
  47. public:
  48.     /**
  49.      * Constructs a KTextEdit object. See QTextEdit::QTextEdit
  50.      * for details.
  51.      */
  52.     KTextEdit( const QString& text,
  53.                const QString& context = QString::null,
  54.                QWidget * parent = 0, const char *name = 0 );
  55.     /**
  56.      * Constructs a KTextEdit object. See QTextEdit::QTextEdit
  57.      * for details.
  58.      */
  59.  
  60.     KTextEdit( QWidget *parent = 0L, const char *name = 0 );
  61.     /**
  62.      * Destroys the KTextEdit object.
  63.      */
  64.     ~KTextEdit();
  65.  
  66.     /**
  67.      * Reimplemented to set a proper "deactivated" background color.
  68.      */
  69.     virtual void setReadOnly (bool readOnly);
  70.  
  71.     /**
  72.      * Reimplemented for tracking custom palettes.
  73.      */
  74.     virtual void setPalette( const QPalette& palette );
  75.  
  76.     /**
  77.      * Turns spell checking for this text edit on or off. Note that spell
  78.      * checking is only available in read-writable KTextEdits.
  79.      *
  80.      * @see checkSpellingEnabled()
  81.      * @see isReadOnly()
  82.      * @see setReadOnly()
  83.      * @since 3.2
  84.      */
  85.     void setCheckSpellingEnabled( bool check );
  86.  
  87.     /**
  88.      * Returns true if spell checking is enabled for this text edit.
  89.      * Note that it even returns true if this is a read-only KTextEdit,
  90.      * where spell checking is actually disabled.
  91.      *
  92.      @ see setCheckSpellingEnabled()
  93.      * @since 3.2
  94.      */
  95.     bool checkSpellingEnabled() const;
  96.  
  97.     void highLightWord( unsigned int length, unsigned int pos );
  98.  
  99.  
  100. public slots:
  101.     /**
  102.      * Create a modal dialog to check the spelling.  This slot will not return
  103.      * until spell checking has been completed.
  104.      *
  105.      * @since 3.2
  106.      */
  107.     void checkSpelling();
  108.  
  109. protected:
  110.     /**
  111.      * Reimplemented to catch "delete word" key events.
  112.      */
  113.     virtual void keyPressEvent( QKeyEvent * );
  114.  
  115.     /**
  116.      * Reimplemented to instantiate a KDictSpellingHighlighter, if
  117.      * spellchecking is enabled.
  118.      */
  119.     virtual void focusInEvent( QFocusEvent * );
  120.  
  121.     /**
  122.      * Reimplemented to allow fast-wheelscrolling with Ctrl-Wheel
  123.      * or zoom.
  124.      */
  125.     virtual void contentsWheelEvent( QWheelEvent * );
  126.  
  127.     /**
  128.      * Deletes a word backwards from the current cursor position,
  129.      * if available.
  130.      */
  131.     virtual void deleteWordBack();
  132.  
  133.     /**
  134.      * Deletes a word forwards from the current cursor position,
  135.      * if available.
  136.      */
  137.     virtual void deleteWordForward();
  138.  
  139.     /**
  140.      * Reimplemented from QTextEdit to add spelling related items
  141.      * when appropriate.
  142.      */
  143.     virtual QPopupMenu *createPopupMenu( const QPoint &pos );
  144.  
  145.     /**
  146.      * This is just a reimplementation of a deprecated method from QTextEdit and
  147.      * is just here to keep source compatibility.  This should not be used in
  148.      * new code.  Specifically reimplementing this method will probably not do
  149.      * what you expect.  See the method above.
  150.      *
  151.      * @deprecated
  152.      */
  153.     virtual QPopupMenu *createPopupMenu();
  154.  
  155. protected:
  156.     virtual void virtual_hook( int id, void* data );
  157.  
  158. private slots:
  159.     void slotSpellCheckReady( KSpell *s );
  160.     void slotSpellCheckDone( const QString &s );
  161.     void spellCheckerMisspelling( const QString &text, const QStringList &, unsigned int pos);
  162.     void spellCheckerCorrected( const QString &, const QString &, unsigned int );
  163.     void spellCheckerFinished();
  164.     void toggleAutoSpellCheck();
  165.     void slotAllowTab();
  166.  
  167. private:
  168.     void posToRowCol( unsigned int pos, unsigned int &line, unsigned int &col );
  169.  
  170.     class KTextEditPrivate;
  171.     KTextEditPrivate *d;
  172. };
  173.  
  174. #endif // KTEXTEDIT_H
  175.